<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/29 0029
 * Time: 10:05
 */
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;

?>
<!DOCTYPE html>
<html>
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
    <meta name="renderer" content="webkit" />
    <title>基本资料</title>
    <link href="http://wenda.ghostchina.com/static/css/default/ico/favicon.ico?v=20140930" rel="shortcut icon" type="image/x-icon" />

   <link rel="stylesheet" type="text/css" href="http://wenda.ghostchina.com/static/css/bootstrap.css" />
<!--   <link rel="stylesheet" type="text/css" href="http://wenda.ghostchina.com/static/css/icon.css" />-->

    <link href="http://wenda.ghostchina.com/static/css/default/common.css?v=20140930" rel="stylesheet" type="text/css" />
    <link href="http://wenda.ghostchina.com/static/css/default/link.css?v=20140930" rel="stylesheet" type="text/css" />
    <link href="http://wenda.ghostchina.com/static/js/plug_module/style.css?v=20140930" rel="stylesheet" type="text/css" />
    <link href="http://wenda.ghostchina.com/static/css/default/user-setting.css?v=20140930" rel="stylesheet" type="text/css" />


    <script type="text/javascript">
        <!--       城市连级begin      -->
        function set_city(province,city) {
            var pv,cv;
            var i,ii;
            pv=province.value;
            cv=city.value;

            city.length=1;
            if(pv=="0")return;
            $.ajax({
                type: "POST",
                url: "<?php echo Url::to(['user/city'])?>",
                dataType:"json",
                data: {province:pv},
                'success': function(json)
                {
                    if(json.status) {
                        console.log(json);
                        for (i=0;i<=json.data.length;i++){
                            ii=i+1;
                            city.options[ii]=new Option();
                            city.options[ii].text=json.data[i]['name'];
                            city.options[ii].value=json.data[i]['id'];
                        }
                    }
                }
            });
        }
        <!--       城市连级end      -->

        <!--       性别加载处理begin    -->
        function regsex() {
            var sex = <?=Html::encode(" {$selectRegname['regsex']}")?>;
            if(sex==1) {
                document.getElementById("sex1").checked=true;
            } else if(sex==2) {
                document.getElementById("sex2").checked=true;
            }else{
                document.getElementById("sex3").checked=true;
            }
        }
        <!--       性别加载处理end    -->

        <!--       城市加载处理begin    -->
        function city() {
            var selectcityid='<?=Html::encode("{$selectcityid['id']}")?>';
            var selectcityname='<?=Html::encode("{$selectcityid['name']}")?>';
            var selcetcityparentid='<?=Html::encode("{$selcetcityparentid['id']}")?>';
            var selcetcityparentname='<?=Html::encode("{$selcetcityparentid['name']}")?>';
            if (selectcityid=='')return;
            else if (selcetcityparentid='')return;
            else{
                $("#province").find("option[text='"+selectcityname+"']").attr("selected",true);
                $("#city").find("option[text='"+selcetcityparentname+"']").attr("selected",true);3
            }
        }
        <!--       城市加载处理end    -->

        <!--       生日加载处理begin    -->
        function birthday() {
            var birthday_y = <?=Html::encode(" {$regbirthday['0']}")?>;
            var birthday_m = <?=Html::encode(" {$regbirthday['1']}")?>;
            var birthday_d = <?=Html::encode(" {$regbirthday['2']}")?>;
            var selects = document.getElementsByTagName("select");//通过标签名获取select对象
        }
        <!--       生日加载处理end    -->

        <!--       日期begin      -->
        window.onload=function() {
            city();
            regsex();//加载性别方法
//            birthday();//加载生日方法
            var selects = document.getElementsByTagName("select");//通过标签名获取select对象
            var date = new Date();
            var nowYear = date.getFullYear();//获取当前的年
            for(var i=nowYear-100;i<=nowYear;i++){
                var optionYear = document.createElement("option");
                optionYear.innerHTML=i;
                optionYear.value=i;
                selects[0].appendChild(optionYear);
            }
            for(var i=1;i<=12;i++){
                var optionMonth = document.createElement("option");
                optionMonth.innerHTML=i;
                optionMonth.value=i;
                selects[1].appendChild(optionMonth);
            }
            getDays(selects[1].value,selects[0].value,selects);
        };

        // 获取某年某月存在多少天
        function getDaysInMonth(month,year){
            var days;
            if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) {
                days=31;
            }else if (month==4 || month==6 || month==9 || month==11){
                days=30;
            }else{
                if ((year%4 == 0 && year%100 != 0) || (year%400 == 0)) {     // 判断是否为润二月
                    days=29;
                }else {
                    days=28;
                }
            }
            return days;
        }
        function setDays(){
            var selects = document.getElementsByTagName("select");
            var year = selects[0].options[selects[0].selectedIndex].value;
            var month = selects[1].options[selects[1].selectedIndex].value;
            getDays(month,year,selects);
        }
        function getDays(month,year,selects){
            var days = getDaysInMonth(month,year);
            selects[2].options.length = 0;
            for(var i=1;i<=days;i++){
                var optionDay = document.createElement("option");
                optionDay.innerHTML=i;
                optionDay.value=i;
                selects[2].appendChild(optionDay);
            }
        }
        <!--       日期end      -->
    </script>


</head>
<noscript unselectable="on" id="noscript">
    <div class="aw-404 aw-404-wrap container">
        <img src="http://wenda.ghostchina.com/static/common/no-js.jpg">
        <p>你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!</p>
    </div>
</noscript>
<body>
<div class="aw-container-wrap">
    <div class="container">
        <div class="row">
            <div class="aw-content-wrap clearfix">
                <div class="aw-user-setting">
                    <div class="tabbable">
                        <ul class="nav nav-tabs aw-nav-tabs active">
                            <li class="active"><a href="#">基本资料</a></li>
                            <h2><i class="icon icon-setting"></i> 用户设置</h2>
                        </ul>
                    </div>

                    <div class="tab-content clearfix">
                        <!-- 基本信息 -->
                        <div class="aw-mod">
                            <div class="mod-body">
                                <div class="aw-mod mod-base">
                                    <div class="mod-head">
                                        <h3>基本信息</h3>
                                    </div>
                                    <form id="setting_form" method="post" action="<?php echo Url::to(['user/information-submit'])?>">
                                        <div class="mod-body">
                                            <dl>
                                                <dt>账号:</dt>
                                                <dd><?=Yii::$app->session->get("regname")?></dd>
                                            </dl>
                                            <dl>
                                                <dt>真实姓名:</dt>
                                                <dd class="introduce">
                                                    <input type="text"  class="form-control"  name="regrealname" value="<?=Html::encode("{$selectRegname['regrealname']}")?>" id="regrealname" required autofocus/>
                                                </dd>
                                            </dl>
                                            <dl>
                                                <dt>性别:</dt>
                                                <dd>
                                                    <label>
                                                        <input name="sex" id="sex1" value="1" type="radio" /> 男						</label>
                                                    <label>
                                                        <input name="sex" id="sex2" value="2" type="radio" /> 女						</label>
                                                    <label>
                                                        <input name="sex" id="sex3" value="3" type="radio" checked="checked" /> 保密						</label>
                                                </dd>
                                            </dl>
                                            <dl>
                                                <dt>生日:</dt>
                                                <dd>
                                                    <select id="birthday_y" name="birthday_y" onchange="setDays()">

                                                    </select>
                                                    <span>年</span>
                                                    <select id="birthday_m" name="birthday_m" onchange="setDays()"></select>
                                                    <span>月</span>
                                                    <select id="birthday_d" name="birthday_d"></select><span>日</span>
                                                </dd>
                                            </dl>
                                            <dl>
                                                <dt><label>现居:</label></dt>
                                                <dd>
                                                    <select name="province" id="province" class="select_area" onchange="set_city(this,this.form.city);">
                                                        <option value="0" id="one">请选择省</option>
                                                        <?php foreach ($selectcityall as $cityall):?>

                                                            <?php if ($cityall->id==0)?>
                                                            <option value="<?=Html::encode("{$cityall->id}")?>" ><?=Html::encode("{$cityall->name}")?></option>
                                                         <?php endforeach;?>
                                                    </select>
                                               <select name="city" id="city" class="select_area">
                                                        <option value="0" id="two">请选择市</option>
                                                    </select>

                                                </dd>
                                            </dl>

                                            <dl>
                                                <dt><label>介绍:</label></dt>
                                                <dd class="introduce"><input class="form-control" id="regintroduce" name="regintroduce" maxlength="128" type="text" value="<?=Html::encode("{$selectRegname['regintroduce']}")?>" /></dd>
                                            </dl>

                                        </div>
                                </div>
                                <!-- end 基本信息 -->

                                <!-- 联系方式 -->
                                <div class="aw-mod mod-contact">
                                    <div class="mod-head">
                                        <h3>联系方式</h3>
                                    </div>
                                    <div class="mod-body clearfix">
                                        <ul>
                                            <li>
                                                <label for="input-qq">QQ :</label>
                                                <input class="form-control" type="text" id="regqq" name="regqq" value="<?=Html::encode("{$selectRegname['regqq']}")?>" />
                                            </li>
                                            <li>
                                                <label for="input-mobile">手机号码 :</label>
                                                <input class="form-control" type="text" id="regmobile" name="regmobile" value="<?=Html::encode("{$selectRegname['regmobile']}")?>" />
                                            </li>
                                            <li>
                                                <label for="input-common-email">常用邮箱 :</label>
                                                <input class="form-control" type="text" id="regemail" name="regemail" value="<?=Html::encode("{$selectRegname['regemail']}")?>" />
                                            </li>
                                            <li>
                                                <label for="input-homepage">网站 :</label>
                                                <input class="form-control" type="text" id="reghomepage" name="reghomepage" value="<?=Html::encode("{$selectRegname['reghomepage']}")?>" />
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="mod-footer clearfix">
                                    <button class="btn btn-large btn-success pull-right" type="submit" name="login" id="loginButton">保存</button>
                                </div>
                                </form>

                                <!-- 上传头像 -->
                                <div class="side-bar">
                                    <dl>
                                        <dt class="pull-left"><img class="aw-border-radius-5" src="http://wenda.ghostchina.com/static/common/avatar-max-img.png?rand=459" alt="" id="avatar_src" /></dt>
                                        <dd class="pull-left">
                                            <h5>头像设置</h5>
                                            <?php $form =ActiveForm::begin(['action'=>'test','options'=>['enctype'=>'multipart/form-data']])?>
                                            <?=$form->field($model,'file')->fileInput()?>
                                            <button class="btn btn-mini btn-success" id="avatar_uploader">上传头像</button> <span id="avatar_uploading_status" class="hide"><i class="aw-loading"></i> 文件上传中...</span>
                                            <?php ActiveForm::end()?>
                                        </dd>
                                    </dl>
                                </div>
                                <!-- end 上传头像 -->

                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div><div class="aw-footer-wrap">
    <div class="aw-footer">
        personal

        <span class="hide">Powered By <a href="#" target="blank">WeCenter 3.0 Beta 2</a></span>

    </div>
</div>


</body>
</html>

